--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--[[



]]--
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--- PARAM
    local SPELL_BLAZING_BUTTERFLY_AOE_RADIOUS = 7       -- 焚身蝶火 AOE半径
    local HEALTH_WARNING_PERCENT_THRESHOLD = 0.20                 -- 血量警告百分比阈值
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--- 【焚身蝶火】
    local client_indicator = nil
    local function CanCreateIndicator(inst)
        if inst.replica.hutao_com_talent_tree:IsUnlocked("time_of_butterfly_concealment") or TUNING.HUTAO_DEBUGGING_MODE then
            if inst.replica.hutao_com_butterfly_s_embrace:GetDebuffActiveTime() > 0 then
                return true
            end
        end
        return false
    end
    local color_origin = Vector3(255/255,153/255,50/255)
    local color_warning = Vector3(255/255,0/255,0/255)
    local warning_flag = false

    local function indicator_create(inst)
        if CanCreateIndicator(inst) then
            if client_indicator == nil then                
                local indicator = SpawnPrefab("hutao_sfx_dotted_circle_client")
                indicator.AnimState:SetAddColour(color_origin.x, color_origin.y, color_origin.z, 0)
                indicator.AnimState:SetMultColour(color_origin.x, color_origin.y, color_origin.z, 1)
                indicator.AnimState:SetBloomEffectHandle("shaders/anim.ksh")    
                indicator:PushEvent("Set",{pt = Vector3(0,0,0),radius = SPELL_BLAZING_BUTTERFLY_AOE_RADIOUS})
                inst:AddChild(indicator)
                client_indicator = indicator
            end
            ---- 闪烁警告
            if inst.replica.health:GetPercent() <= HEALTH_WARNING_PERCENT_THRESHOLD then
                local color = warning_flag and color_warning or color_origin
                client_indicator.AnimState:SetAddColour(color.x, color.y, color.z, 0)
                client_indicator.AnimState:SetMultColour(color.x, color.y, color.z, 1)
                warning_flag = not warning_flag
            end
        elseif inst.replica.hutao_com_butterfly_s_embrace:GetDebuffActiveTime() <= 0 and client_indicator ~= nil then
            client_indicator:Remove()
            client_indicator = nil
        end
    end
    local function install_indicator_task(inst)
        if inst == ThePlayer and inst.HUD then
            inst:ListenForEvent("hutao_com_butterfly_s_embrace_update",indicator_create)
        end
    end
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--- 【血梅香】
    local function blood_plum_scent_event(inst,_table)
        local hit_times = _table and _table.hit or 0
        local target = _table and _table.target or nil
        print("血梅香",target,hit_times)
        if hit_times >= (TUNING.HUTAO_DEBUGGING_MODE and 2 or 25) then
            inst.components.hutao_com_dialogue:SayWithCD("hutao_debuff_blood_plum_scent.more_hit",10)
        end
    end
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

return function(inst)
    inst:DoTaskInTime(1, install_indicator_task)
    if not TheWorld.ismastersim then
        return
    end
    inst:ListenForEvent("hutao_com_blood_plum_scent_for_debuff.damage", blood_plum_scent_event)
end